home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / internet / amitcp3.0b / src.lha / src / amitcp / sys / protosw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  10.3 KB  |  258 lines

  1. /*
  2.  * $Id: protosw.h,v 1.8 1993/06/04 11:16:15 jraja Exp $
  3.  *
  4.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  5.  *                    Helsinki University of Technology, Finland.
  6.  *                    All rights reserved.
  7.  *
  8.  * HISTORY
  9.  * $Log: protosw.h,v $
  10.  * Revision 1.8  1993/06/04  11:16:15  jraja
  11.  * Fixes for first public release.
  12.  *
  13.  * Revision 1.7  1993/05/17  01:02:04  ppessi
  14.  * Changed RCS version
  15.  *
  16.  * Revision 1.6  1993/04/13  21:58:33  jraja
  17.  * Updated function pointer prototypes to compile with SAS.
  18.  *
  19.  * Revision 1.5  93/04/11  22:23:32  22:23:32  jraja (Jarno Tapio Rajahalme)
  20.  * Changed ellipses to prototypes.
  21.  * 
  22.  * Revision 1.4  93/03/05  03:29:37  03:29:37  ppessi (Pekka Pessi)
  23.  * Compiles with SASC. Initial test version.
  24.  * 
  25.  * Revision 1.3  93/03/03  20:29:59  20:29:59  jraja (Jarno Tapio Rajahalme)
  26.  * Moved prurequest array from here to netinet/tcp_debug.c.
  27.  * 
  28.  * Revision 1.2  93/03/03  18:49:55  18:49:55  jraja (Jarno Tapio Rajahalme)
  29.  * Eliminated definitions which would define storage (name tables),
  30.  * hide old prototypes for pffindproto() and pffindtype().
  31.  * Added #ifndef SYS_PROTOSW_H etc.
  32.  * 
  33.  * Revision 1.1  92/11/20  15:42:15  15:42:15  jraja (Jarno Tapio Rajahalme)
  34.  * Initial revision
  35.  * 
  36.  *
  37.  */
  38.  
  39. /*-
  40.  * Copyright (c) 1982, 1986 The Regents of the University of California.
  41.  * All rights reserved.
  42.  *
  43.  * Redistribution and use in source and binary forms, with or without
  44.  * modification, are permitted provided that the following conditions
  45.  * are met:
  46.  * 1. Redistributions of source code must retain the above copyright
  47.  *    notice, this list of conditions and the following disclaimer.
  48.  * 2. Redistributions in binary form must reproduce the above copyright
  49.  *    notice, this list of conditions and the following disclaimer in the
  50.  *    documentation and/or other materials provided with the distribution.
  51.  * 3. All advertising materials mentioning features or use of this software
  52.  *    must display the following acknowledgement:
  53.  *    This product includes software developed by the University of
  54.  *    California, Berkeley and its contributors.
  55.  * 4. Neither the name of the University nor the names of its contributors
  56.  *    may be used to endorse or promote products derived from this software
  57.  *    without specific prior written permission.
  58.  *
  59.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  60.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  61.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  62.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  63.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  64.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  65.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  66.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  67.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  68.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  69.  * SUCH DAMAGE.
  70.  *
  71.  *    @(#)protosw.h    7.8 (Berkeley) 4/28/91
  72.  */
  73.  
  74. #ifndef SYS_PROTOSW_H
  75. #define SYS_PROTOSW_H
  76.  
  77. /*
  78.  * Protocol switch table.
  79.  *
  80.  * Each protocol has a handle initializing one of these structures,
  81.  * which is used for protocol-protocol and system-protocol communication.
  82.  *
  83.  * A protocol is called through the pr_init entry before any other.
  84.  * Thereafter it is called every 200ms through the pr_fasttimo entry and
  85.  * every 500ms through the pr_slowtimo for timer based actions.
  86.  * The system will call the pr_drain entry if it is low on space and
  87.  * this should throw away any non-critical data.
  88.  *
  89.  * Protocols pass data between themselves as chains of mbufs using
  90.  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
  91.  * UNIX) and pr_output passes it down (towards the imps); control
  92.  * information passes up and down on pr_ctlinput and pr_ctloutput.
  93.  * The protocol is responsible for the space occupied by any the
  94.  * arguments to these entries and must dispose it.
  95.  *
  96.  * The userreq routine interfaces protocols to the system and is
  97.  * described below.
  98.  */
  99. struct protosw {
  100.     short    pr_type;        /* socket type used for */
  101.     struct    domain *pr_domain;    /* domain protocol a member of */
  102.     short    pr_protocol;        /* protocol number */
  103.     short    pr_flags;        /* see below */
  104. /* protocol-protocol hooks */
  105.     void    (* STKARGFUN pr_input)(...);        /* input to protocol (from below) */
  106.     int    (* STKARGFUN pr_output)(...);        /* output to protocol (from above) */
  107.     void    (*pr_ctlinput)(int cmd,    /* control input (from below) */
  108.                    struct sockaddr *sa, void *arg);
  109.     int    (*pr_ctloutput)(int req, /* control output (from above) */
  110.                 struct socket *so, int level, int optname,
  111.                 struct mbuf **optval);
  112. /* user-protocol hook */
  113.     int    (*pr_usrreq)(struct socket *,/* user request: see list below */
  114.                  int req, struct mbuf *m, struct mbuf *nam,
  115.                  struct mbuf *control);
  116. /* utility hooks */
  117.     void    (*pr_init)(void);    /* initialization hook */
  118.     void    (*pr_fasttimo)(void);    /* fast timeout (200ms) */
  119.     void    (*pr_slowtimo)(void);    /* slow timeout (500ms) */
  120.     void    (*pr_drain)(void);    /* flush any excess space possible */
  121. };
  122.  
  123. #define    PR_SLOWHZ    2        /* 2 slow timeouts per second */
  124. #define    PR_FASTHZ    5        /* 5 fast timeouts per second */
  125.  
  126. /*
  127.  * Values for pr_flags.
  128.  * PR_ADDR requires PR_ATOMIC;
  129.  * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
  130.  */
  131. #define    PR_ATOMIC    0x01        /* exchange atomic messages only */
  132. #define    PR_ADDR        0x02        /* addresses given with messages */
  133. #define    PR_CONNREQUIRED    0x04        /* connection required by protocol */
  134. #define    PR_WANTRCVD    0x08        /* want PRU_RCVD calls */
  135. #define    PR_RIGHTS    0x10        /* passes capabilities */
  136.  
  137. /*
  138.  * The arguments to usrreq are:
  139.  *    (*protosw[].pr_usrreq)(up, req, m, nam, opt);
  140.  * where up is a (struct socket *), req is one of these requests,
  141.  * m is a optional mbuf chain containing a message,
  142.  * nam is an optional mbuf chain containing an address,
  143.  * and opt is a pointer to a socketopt structure or nil.
  144.  * The protocol is responsible for disposal of the mbuf chain m,
  145.  * the caller is responsible for any space held by nam and opt.
  146.  * A non-zero return from usrreq gives an
  147.  * UNIX error number which should be passed to higher level software.
  148.  */
  149. #define    PRU_ATTACH        0    /* attach protocol to up */
  150. #define    PRU_DETACH        1    /* detach protocol from up */
  151. #define    PRU_BIND        2    /* bind socket to address */
  152. #define    PRU_LISTEN        3    /* listen for connection */
  153. #define    PRU_CONNECT        4    /* establish connection to peer */
  154. #define    PRU_ACCEPT        5    /* accept connection from peer */
  155. #define    PRU_DISCONNECT        6    /* disconnect from peer */
  156. #define    PRU_SHUTDOWN        7    /* won't send any more data */
  157. #define    PRU_RCVD        8    /* have taken data; more room now */
  158. #define    PRU_SEND        9    /* send this data */
  159. #define    PRU_ABORT        10    /* abort (fast DISCONNECT, DETATCH) */
  160. #define    PRU_CONTROL        11    /* control operations on protocol */
  161. #define    PRU_SENSE        12    /* return status into m */
  162. #define    PRU_RCVOOB        13    /* retrieve out of band data */
  163. #define    PRU_SENDOOB        14    /* send out of band data */
  164. #define    PRU_SOCKADDR        15    /* fetch socket's address */
  165. #define    PRU_PEERADDR        16    /* fetch peer's address */
  166. #define    PRU_CONNECT2        17    /* connect two sockets */
  167. /* begin for protocols internal use */
  168. #define    PRU_FASTTIMO        18    /* 200ms timeout */
  169. #define    PRU_SLOWTIMO        19    /* 500ms timeout */
  170. #define    PRU_PROTORCV        20    /* receive from below */
  171. #define    PRU_PROTOSEND        21    /* send to below */
  172.  
  173. #define    PRU_NREQ        21
  174.  
  175. /*
  176.  * moved prurequests array definition to netinet/tcp_debug.c
  177.  */
  178. #ifdef PRUREQUESTS
  179. extern char *prurequests[];
  180. #endif
  181.  
  182. /*
  183.  * The arguments to the ctlinput routine are
  184.  *    (*protosw[].pr_ctlinput)(cmd, sa, arg);
  185.  * where cmd is one of the commands below, sa is a pointer to a sockaddr,
  186.  * and arg is an optional caddr_t argument used within a protocol family.
  187.  */
  188. #define    PRC_IFDOWN        0    /* interface transition */
  189. #define    PRC_ROUTEDEAD        1    /* select new route if possible ??? */
  190. #define    PRC_QUENCH2        3    /* DEC congestion bit says slow down */
  191. #define    PRC_QUENCH        4    /* some one said to slow down */
  192. #define    PRC_MSGSIZE        5    /* message size forced drop */
  193. #define    PRC_HOSTDEAD        6    /* host appears to be down */
  194. #define    PRC_HOSTUNREACH        7    /* deprecated (use PRC_UNREACH_HOST) */
  195. #define    PRC_UNREACH_NET        8    /* no route to network */
  196. #define    PRC_UNREACH_HOST    9    /* no route to host */
  197. #define    PRC_UNREACH_PROTOCOL    10    /* dst says bad protocol */
  198. #define    PRC_UNREACH_PORT    11    /* bad port # */
  199. /* was    PRC_UNREACH_NEEDFRAG    12       (use PRC_MSGSIZE) */
  200. #define    PRC_UNREACH_SRCFAIL    13    /* source route failed */
  201. #define    PRC_REDIRECT_NET    14    /* net routing redirect */
  202. #define    PRC_REDIRECT_HOST    15    /* host routing redirect */
  203. #define    PRC_REDIRECT_TOSNET    16    /* redirect for type of service & net */
  204. #define    PRC_REDIRECT_TOSHOST    17    /* redirect for tos & host */
  205. #define    PRC_TIMXCEED_INTRANS    18    /* packet lifetime expired in transit */
  206. #define    PRC_TIMXCEED_REASS    19    /* lifetime expired on reass q */
  207. #define    PRC_PARAMPROB        20    /* header incorrect */
  208.  
  209. #define    PRC_NCMDS        21
  210.  
  211. #define    PRC_IS_REDIRECT(cmd)    \
  212.     ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
  213.  
  214. #ifndef AMITCP /* this would define storage in header, ugly */
  215. #ifdef PRCREQUESTS
  216. char    *prcrequests[] = {
  217.     "IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2",
  218.     "QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
  219.     "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
  220.     "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
  221.     "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
  222.     "PARAMPROB"
  223. };
  224. #endif
  225. #endif /* AMITCP */
  226.  
  227. /*
  228.  * The arguments to ctloutput are:
  229.  *    (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
  230.  * req is one of the actions listed below, so is a (struct socket *),
  231.  * level is an indication of which protocol layer the option is intended.
  232.  * optname is a protocol dependent socket option request,
  233.  * optval is a pointer to a mbuf-chain pointer, for value-return results.
  234.  * The protocol is responsible for disposal of the mbuf chain *optval
  235.  * if supplied,
  236.  * the caller is responsible for any space held by *optval, when returned.
  237.  * A non-zero return from usrreq gives an
  238.  * UNIX error number which should be passed to higher level software.
  239.  */
  240. #define    PRCO_GETOPT    0
  241. #define    PRCO_SETOPT    1
  242.  
  243. #define    PRCO_NCMDS    2
  244.  
  245. #ifndef AMITCP /* this would define storage in header, ugly */
  246. #ifdef PRCOREQUESTS
  247. char    *prcorequests[] = {
  248.     "GETOPT", "SETOPT",
  249. };
  250. #endif
  251.  
  252. #ifdef KERNEL
  253. extern    struct protosw *pffindproto(), *pffindtype();
  254. #endif
  255. #endif /* AMITCP */
  256.  
  257. #endif /* !SYS_PROTOSW_H */
  258.